<?php //echo "<pre>"; die(print_r($list_tvshow));        ?>


<div id="sidebar">
    <a href="#" id="sidebar_button"><span class="fa fa-bars"></span></a>
    <div class="inner">
        <a id="logo" href="<?php echo $baseurl; ?>">
            <img src="<?php echo $baseurl; ?>public/images/vtv-now.png"/>

        </a>
        <a href="#" class="Mute"></a>
        <div class="scroller">
            <div class="scroll_inner">
                <ul class="menu">
                    <li <?php
                    if ($controller == 'index') {
                        echo 'class="active"';
                    }
                    ?>><a data-link="href" href="<?php echo $baseurl; ?>"><span>Trang chủ</span></a></li>
                    <li <?php
                    if ($controller == 'user') {
                        echo 'class="active"';
                    }
                    ?>><a data-link="href" href="<?php echo $baseurl; ?>tai-khoan.html"><span>Tài khoản</span></a></li>
                        <?php
                        $i = 1;
                        foreach ($list_tvshow as $item) {
                            ?>
                        <li <?php
                        if ($controller == 'tvshow' && (@$data ? @$data->id : 0) == $item['id']) {
                            echo 'class="active"';
                        }
                        ?>>
                            <a <?php if ($item['starting'] == 1): ?>data-link="href"<?php endif; ?> data-starting="<?php echo $item['starting']; ?>" data-time="<?php echo $item['schedule']; ?>" data-channel_logo="<?php echo $item['logo']; ?>" data-poster="<?php echo $item['program_logo']; ?>" href="<?php echo $baseurl; ?>chuong-trinh/<?php echo $item['name_ascii']; ?>.html"><span><?php echo $item['name']; ?></span></a> 
                            <?php if ($item['follow'] == 1): ?>
                                <button data-id="<?php echo $item['id']; ?>" class="btn follow-button btn-unfollow follow-<?php echo $item['id']; ?>"></button>
                            <?php else: ?>
                                <button data-id="<?php echo $item['id']; ?>" class="btn follow-button btn-follow follow-<?php echo $item['id']; ?>"></button>
                            <?php endif; ?>
                        </li>
                    <?php } ?>
                </ul>
            </div>
        </div>
        <div class="footer">

            <div class="apps">
                <a class="ios qrcode" data-qr="qr-ios" href="<?php echo $list_qrcode['link_ios']; ?>"></a>
                <a class="android qrcode" data-qr="qr-android" href="<?php echo $list_qrcode['link_android']; ?>"></a>
                <a class="wp qrcode" data-qr="qr-wp" href="<?php echo $list_qrcode['link_ios']; ?>"></a>

                <div class="dialog-qr" style="display: none;">
                    <div class="dialog-qr-outside"></div>
                    <div class="dialog-qr-box">
                        <div class="dialog-qr-inside">
                            <img class="qr-ios" alt="qrcode ios version" src="<?php echo $imgurl . $list_qrcode['image_qrcode_ios']; ?>" onerror="this.src='<?php echo $baseurl; ?>public/images/bg-sidebar.png';"/>
                            <img class="qr-android" alt="qrcode android version" src="<?php echo $imgurl . $list_qrcode['image_qrcode_android']; ?>" onerror="this.src='<?php echo $baseurl; ?>public/images/bg-sidebar.png';"/>
                            <img class="qr-wp" alt="qrcode wp version" src="<?php echo $imgurl . $list_qrcode['image_qrcode_wp']; ?>" onerror="this.src='<?php echo $baseurl; ?>public/images/bg-sidebar.png';"/>
                            <p>Quét mã QR Code để tải ứng dụng về điện thoại</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="infoabout">
                Sản phẩm của <img src="<?php echo $baseurl; ?>public/images/vtv-digital.png" alt=""/>
                <p>Phát triển bởi <a href="#" data-schedule='0' data-poster='public/uploads/poster_duongtoivuongmien.jpg'>Gvtechcom</a></p>
            </div>
        </div>       
    </div>
</div>

<script>
    $(document).ready(function () {

        $('.follow-button').on('click', function () {
            if (rl == "guest") {
                UI_Dialog.showConfirm({
                    title: "VTV NOW Thông báo",
                    content: "Vui lòng đăng nhập để thao tác.",
                    buttons: [{
                            id: "Confirm_cancel",
                            text: "Đóng lại"
                        },
                        {
                            id: "Confirm_login",
                            text: "Đăng nhập"
                        }],
                    event: function () {
                        $("#Confirm_login").on("click", function () {
                            UI_Dialog.close(function () {
                                window.location.href = App.Base_Url + "tai-khoan.html";
                            });
                        });
                    }
                });
                return  false;
            }
            var $this = $(this);
            var $id_tvshow = $(this).data('id');
            $.ajax({
                type: "GET",
                url: '<?php echo $baseapi; ?>follow',
                data: ({user_id: <?php echo $this->session->userdata('id_mem') ? $this->session->userdata('id_mem') : 0 ?>, id_tvshow: $id_tvshow, __show_bk: '<?php echo $this->security->get_csrf_hash(); ?>'}),
                success: function (data) {
                    //$this.removeClass('btn-follow').addClass('btn-unfollow');
                    if ($this.hasClass('btn-follow')) {
                        $('.follow-' + $id_tvshow).removeClass('btn-follow').addClass('btn-unfollow');
                    } else if ($this.hasClass('btn-unfollow')) {
                        $('.follow-' + $id_tvshow).removeClass('btn-unfollow').addClass('btn-follow');
                    }
                }
            });
            
            $.ajax({
                type: "GET",
                url: '<?php echo $baseurl; ?>ajax-plus-flag0',
                data: ({ }),
                success: function (data) {
						console.log('flag: '+data);
                }
            });

        });
    });
</script>